#include "publicUtil.hpp"


double getDistance(Point p1, Point p2)
{
    double distance = pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2);
    distance = sqrt(distance);
    return distance;
}

string convFloatToSring(float a)
{
    char s[40];
    string s_;
    sprintf(s,"%.2f",a);
    s_ = s;
    return s_;
}

void drawRotateRect(Mat src,RotatedRect temp)
{
    // 绘制旋转矩阵
    Point2f temp_[4];
    temp.points(temp_);
    for(int i = 0; i < 4; i++)
    {
        line(src, temp_[i], temp_[(i+1) % 4], Scalar(0,0,255), 2, 8);
    }
    return;
}

Point getRotateRectCenter(RotatedRect temp1)
{
    Point2f edge_points[4];
    temp1.points(edge_points);
    return Point((edge_points[0].x + edge_points[2].x)/2,(edge_points[0].y + edge_points[2].y)/2);
}

void drawRect(Mat src,Rect rect)
{
    rectangle(src,rect,Scalar(255,255,255));
}